package com.yfz.day05;

/**
 * 713. 乘积小于 K 的子数组
 */
class Solution {
    public int numSubarrayProductLessThanK(int[] nums, int k) {
        int max = Integer.MAX_VALUE;
        int len = nums.length;
        int num = 0;
        int start = 0 ;
        int sum = 1;
        for(int end = 0 ; end < len ; end ++)
        {
            sum *= nums[end];
            while(start<= end && sum>= k )
            {
                sum/=nums[start];
                start++;
            }
            num+=(end - start +1);
        }

        return num;
    }
}